<!-- 附件展示，下载 -->
<template>
  <div class="fileList">
    <div
      v-for="(file, index) in value"
      :key="index"
      class="download-link"
      @click="downloadFile(file)"
    >
      {{ file.name }}
    </div>
    <div v-if="!value.length">无附件</div>
  </div>
</template>

<script>
import formMixin from 'vue-ele-form/lib/mixins/formMixin'
import coverApi from '@/api/cover'

export default {
  name: 'file-list',
  mixins: [formMixin],
  props: {
    value: {
      type: Array,
      default: () => []
    },
    files: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    downloadFile(file) {
      coverApi.plantaskDownloadFile(file.fileId)
    }
  }
}
</script>

<style lang="less" scoped>
.fileList {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  .download-link {
    cursor: pointer;
    color: #0056b3;
    text-decoration: underline;
    margin-left: 10px;
    &:hover {
      color: #f89c34;
    }
  }
}

</style>